home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9606 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: solon.com!not-for-mail
  2. From: tanmoy@qcd.Lanl.GOV (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated
  4. Subject: Re: Integral promotion problem
  5. Date: 11 Mar 1996 19:29:14 -0600
  6. Organization: Los Alamos National Laboratory
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4i2k1a$8ju@solutions.solon.com>
  10. References: <31404525.26295649@dub-news-svc-3.compuserve.com>
  11.     <4i169k$ht@solutions.solon.com>
  12. NNTP-Posting-Host: solutions.solon.com
  13.  
  14. In article <4i169k$ht@solutions.solon.com>
  15. johnb@pivotal-dm.ccmail.compuserve.com (John Bain) writes:
  16. <snip>
  17. JB: "The integral promotions are performed.  If the operand is unsigned, the
  18. JB: result is computed by subtracting the value from the largest value of
  19. JB: the promoted type.  If the operand is signed, the result is computed by
  20. JB: converting the promoted operand to the corresponding unsigned type,
  21. JB: applying ~, and converting it back to the unsigned type."
  22.  
  23. Hmmm. I don't have the standard right here, but I do not remember it
  24. being quite that precise. I think all bits are reversed which leads to
  25. an implementation defined value; but I do not remember a requirement
  26. that this be consistent with unsigned->signed conversion. (I will
  27. follow up again if I am wrong.)
  28.  
  29. JB: 
  30. JB: I didn't believe that the implementation defined unsigned->signed
  31. JB: conversions were happening, but I didn't believe the results I was
  32. JB: seeing either!
  33.  
  34. Integral promotion promotes unsigned short to unsigned int only if int
  35. cannot hold all possible values of unsigned short. I do not remember
  36. exactly what it was, but either I thought you said that your shorts
  37. were _shorter_ than your ints or you were talking about oromotion of
  38. short and not unsigned short. In either case, you never get unsigned
  39. int. So you never need the rule for unsigned to signed conversion.
  40.  
  41. JB: 
  42. JB: Incidentally, I assume that when it says "if the operand is unsigned" it
  43. JB: means _before_ promotion?
  44.  
  45. No.
  46.  
  47. Cheers
  48. Tanmoy
  49. --
  50. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  51. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  52. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  53. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  54. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  55. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  56.